<?php
namespace app\index\controller;

use PhpOffice\PhpWord\TemplateProcessor;
use think\Db;
use think\Controller;

class Makeword extends Controller
{
	public function word($arr)
	{
		Vendor('phpoffice.phpword.bootstrap.php');
        //创建新文档…
        $phpWord = new \PhpOffice\PhpWord\PhpWord();
        $phpWord->setDefaultFontSize(10.5);
        /* 注意:任何添加到文档的元素都必须位于一个区域内。 */
        // 在文档中添加空白部分…
        $section = $phpWord->addSection();
        //页眉
        $header = $section->addHeader();
        $header->addImage('public/static/index/word/logo.png', 
        	array(
        		'width'    => 50,
        		'height'   => 18,
        		// 'marginLeft'    => -1,
                // 'wrappingStyle' => 'behind'
         	)
        );
        $lineStyle = array('weight' => 1, 'width' => 450, 'height' => 2, 'color' => '1B2232','wrappingStyle' => 'behind');
        $header->addLine($lineStyle);

        //头像和个人信息表格
        $imageStyletop = array(
            'width' => 200,
            'height' => 260,
//            'wrappingStyle' => 'square',
//            'positioning' => 'absolute',
//            'posHorizontalRel' => 'margin',
//            'posVerticalRel' => 'line',
        );
        $fontStyleName = array(
            'name' => '微软雅黑',
            'size' => 10.5,
            'color' => '1B2232',
            'blod' => 'false'
        );
        $tableStyle = array(
            'borderColor' => 'ffffff',
            'borderSize' =>0,
            'width' => 9000,
            'textDirection' => 'tbR1',
            'valign' => 'left'
        );
        $table = $section->addTable($tableStyle);
        $table->addRow(5200);
//        $table->addCell(4200)->addImage(substr($arr['img_url'],1),$imageStyletop);

        $newimgname = 'new_'.substr('.'.$arr['img_url'],strripos('.'.$arr['img_url'],'/')+4); //新图名称加后缀
        $newimgurl = substr('.'.$arr['img_url'],0,strripos('.'.$arr['img_url'],'/')+1); //新图url/
        copy(substr($arr['img_url'],1),substr($newimgurl,2).$newimgname); //复制原图到新图路径
        $image = \think\Image::open($newimgurl.$newimgname);//新图路径 ./
        $image->thumb($imageStyletop['width']*5/0.75,$imageStyletop['height']*5/0.75)->save($newimgurl.$newimgname,null,100); //压缩新图,质量100
        $newurl = $newimgurl.$newimgname;//新图
//        dump($newimgurl.$newimgname);
//            halt($newurl);
//        $table->addCell(4200)->addImage('.'.$newurl['url'],$imageStyletop); //加样式的
        $table->addCell(4200)->addImage($newurl,['width'=>150]); //不加样式word中图片不会变形,样式提前压缩图片计算好
        $table->addCell(4200)->addText(
            $arr['name'].'<w:br />'.'英文名：'.
            $arr['en_name'].'        性别：'.
            $arr['sex'].'<w:br />'.'出生日期：'.
            $arr['birthday1'].'-'.$arr['birthday2'].'-'.$arr['birthday3'].'<w:br />'.'手机：'.
            $arr['tel'].'<w:br />'.'身高：'.
            $arr['height'].'(cm)        体重：'.
            $arr['weight'].'(kg)'.'<w:br />'.'Email：'.
            $arr['email'].'<w:br />'.'户籍城市:'.
            $arr['address'].'<w:br />'.'现居城市:'.
            $arr['newaddress'].'<w:br />'.'每周工作天数：'.
            $arr['working_hours'],
            $fontStyleName,array('lineHeight'=>1.7,'indent'=>0.5)
        );
        //类项头部表格
        //
        $imageStyleheader = array(
            'width' => 20,
            'height' => 20,
        );
        $tableStyle1 = array(
            'borderColor' => '1B2232',
            'borderBottomSize'  => 6,
        );
        $firstRowStyle = array('height'=>30);
        $phpWord->addTableStyle('myTable', $tableStyle1, $firstRowStyle);
        $table = $section->addTable('myTable');
        $table->addRow(150);
        $table->addCell(150)->addImage('public/static/index/word/jyjl.jpg',$imageStyleheader);
        $table->addCell(8800)->addText('教育经历',array('name' => '微软雅黑','size'=>12,'color'=>'1B2232','bold'=>true),array('lineHeight'=>1.2,'indent'=>0.2));
        $section->addTextBreak();
        // $section->addText('',array('name' => '微软雅黑','size' => 10.5, 'color' => '1B2232','color'=>'1B2232'),array('lineHeight'=>0.5,'indent'=>0.8));
        $section->addText($arr['school_start1'].'/'.$arr['school_start2'].'--'.$arr['school_end1'].'/'.$arr['school_end2'].'    '.$arr['school'].'    '.$arr['specialty'],array('name' => '微软雅黑', 'size' => 10.5, 'color' => '1B2232','color'=>'1B2232'),array('lineHeight'=>1.7,'indent'=>0.8));
        //左浮动图标
        $table = $section->addTable('myTable');
        $table->addRow(30);
        $table->addCell(30)->addImage('public/static/index/word/gzjl.jpg',$imageStyleheader);
        $table->addCell(8900)->addText('工作经历',array('name' => '微软雅黑','size'=>12,'color'=>'1B2232','bold'=>true),array('lineHeight'=>1.2,'indent'=>0.2));
        $section->addTextBreak();
         // $section->addText('',array('name' => '微软雅黑','size' => 10.5, 'color' => '1B2232','color'=>'1B2232'),array('lineHeight'=>0.5,'indent'=>0.8));
        foreach ($arr['shixi_start1'] as $ks=> $vs) {
        $section->addText($arr['shixi_start1'][$ks].'/'.$arr['shixi_start2'][$ks].'--'.$arr['shixi_end1'][$ks].'/'.$arr['shixi_end2'][$ks].'    '.$arr['shixi_company'][$ks].'    '.$arr['shixi_zw'][$ks].'    '.$arr['shixi_daiyu'][$ks],array('name' => '微软雅黑', 'size' => 10.5, 'color' => '1B2232','color'=>'1B2232'),array('lineHeight'=>1.7,'indent'=>0.8));
        }
        //左浮动图标
        $table = $section->addTable('myTable');
        $table->addRow(30);
        $table->addCell(30)->addImage('public/static/index/word/yynl.jpg',$imageStyleheader);
        $table->addCell(8900)->addText('语言能力',array('name' => '微软雅黑','size'=>12,'color'=>'1B2232','bold'=>true),array('lineHeight'=>1.2,'indent'=>0.2));
        $section->addText('',array('name' => '微软雅黑','size' => 10.5, 'color' => '1B2232','color'=>'1B2232'),array('lineHeight'=>0.5,'indent'=>0.8));
        $section->addText($arr['languages'],array('name' => '微软雅黑', 'size' => 10.5, 'color' => '1B2232','color'=>'1B2232'),array('lineHeight'=>1.7,'indent'=>0.8));
        //左浮动图标
        $table = $section->addTable('myTable');
        $table->addRow(30);
        $table->addCell(30)->addImage('public/static/index/word/qzyx.jpg',$imageStyleheader);
        $table->addCell(8900)->addText('求职意向',array('name' => '微软雅黑','size'=>12,'color'=>'1B2232','bold'=>true),array('lineHeight'=>1.2,'indent'=>0.2));
        $section->addTextBreak();
        // $section->addText('',array('name' => '微软雅黑', 'size' => 10.5, 'color' => '1B2232','color'=>'1B2232'),array('lineHeight'=>0.5,'indent'=>0.8));
        $section->addText($arr['intention'],array('name' => '微软雅黑', 'size' => 10.5, 'color' => '1B2232','color'=>'1B2232'),array('lineHeight'=>1.7,'indent'=>0.8));
        //左浮动图标
        $table = $section->addTable('myTable');
        $table->addRow(30);
        $table->addCell(30)->addImage('public/static/index/word/zwpj.jpg',$imageStyleheader);
        $table->addCell(8900)->addText('自我评价',array('name' => '微软雅黑','size'=>12,'color'=>'1B2232','bold'=>true),array('lineHeight'=>1.2,'indent'=>0.2));
        $section->addTextBreak();
        // $section->addText('',array('name' => '微软雅黑', 'size' => 10.5, 'color' => '1B2232','color'=>'1B2232'),array('lineHeight'=>0.5,'indent'=>0.8));
        $section->addText($arr['introduce'],array('name' => '微软雅黑', 'size' => 10.5, 'color' => '1B2232','color'=>'1B2232'),array('lineHeight'=>1.7,'indent'=>0.8));
        // 将文档保存为OOXML文件…
        $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
        
        $objWriter->save('uploads/word/resumes'.$arr['id'].'.docx');
	}

        public function qz($arr)
        {
                Vendor('phpoffice.phpword.bootstrap.php');
                //创建新文档…
                $phpWord = new \PhpOffice\PhpWord\PhpWord();
                $phpWord->setDefaultFontSize(10.5);
                /* 注意:任何添加到文档的元素都必须位于一个区域内。 */
                // 在文档中添加空白部分…
                $section = $phpWord->addSection();
                //页眉
                $header = $section->addHeader();
                $header->addImage('public/static/index/word/logo.png',
                    array(
                        'width'    => 50,
                        'height'   => 18,
                            // 'marginLeft'    => -1,
                            // 'wrappingStyle' => 'behind'
                    )
                );
                $lineStyle = array('weight' => 1, 'width' => 450, 'height' => 2, 'color' => '1B2232','wrappingStyle' => 'behind');
                $header->addLine($lineStyle);

                //头像和个人信息表格
                $imageStyletop = array(
                    'width' => 150,
                    'height' => 195,
                    'wrappingStyle' => 'square',
                    'positioning' => 'absolute',
                    'posHorizontalRel' => 'margin',
                    'posVerticalRel' => 'line',
                );
//            resizeImage('.'.$arr['img_url'],$imageStyletop['width'],$imageStyletop['height']);//压缩图片
                $fontStyleName = array(
                    'name' => '微软雅黑',
                    'size' => 10.5,
                    'color' => '1B2232',
                    'blod' => 'false'
                );
                $tableStyle = array(
                    'borderColor' => 'ffffff',
                    'borderSize' =>6,
                    'cell'=>50,
                    'width' => 9000,
                    'textDirection' => 'tbR1',
                    'valign' => 'left'
                );
                //$table = $section->addTable($tableStyle);
                $styleTable = array('borderColor'=>'006699',
                    'borderSize'=>6,
                    'cellMargin'=>50);
                $styleFirstRow = array('bgColor'=>'66BBFF');
                $phpWord->addTableStyle('myTable', $styleTable, $styleFirstRow);

                $table = $section->addTable('myTable');
                $table->addRow(1000);
                $table->addCell(100)->addText('姓名:');
                $table->addCell(600)->addText('张三');
                $table->addCell(100)->addText('出生年月:');
                $table->addCell(600)->addText('9999999');
                $table->addCell(100)->addText('最高学历:');
                $table->addCell(600)->addText('大学本科');

                $table->addRow(1000);
                $table->addCell(100)->addText('微信:');
                $table->addCell(600)->addText('1888888888');
                $table->addCell(100)->addText('工作年限:');
                $table->addCell(600)->addText('3');
                $table->addCell(100)->addText('资格证书:');
                $table->addCell(600)->addText('112455');

                $table->addRow(5200);
                //先展示表格的信息
                $table->addCell(4200)->addText(
                    $arr['name'].'<w:br />'.'性别：'.
                    $arr['sex'].'<w:br />'.'出生日期：'.
                    $arr['birthday1'].'-'.$arr['birthday2'].'-'.$arr['birthday3'].'<w:br />'.'最高学历：'.
                    $arr['education'].'<w:br />'.'微信：'.
                    $arr['wechat'].'<w:br />'.'工作年限：'.
                    $arr['years'].'<w:br />'.'资格证书：'.
                    $arr['qualification'].'<w:br />'.'手机：'.
                    $arr['tel'].'<w:br />'.'现居城市:'.
                    $arr['newaddress'].'<w:br />'.'Email：'.
                    $arr['email'].'<w:br />'.'户籍城市:'.
                    $arr['address'],
                    $fontStyleName,array('lineHeight'=>1.7,'indent'=>0.5)
                );

//                $table->addCell(4200)->addImage(substr($arr['img_url'],1),$imageStyletop);
            $newurl = resizeImage('.'.$arr['img_url'],$imageStyletop['width'],$imageStyletop['height']);
            $table->addCell(4200)->addImage(substr($newurl['url'],1),$imageStyletop);
                //类项头部表格  顶部信息展示完成
                //
                $imageStyleheader = array(
                    'width' => 20,
                    'height' => 20,
                );
                $tableStyle1 = array(
                    'borderColor' => '1B2232',
                    'borderBottomSize'  => 6,
                );
                $firstRowStyle = array('height'=>30);
                $phpWord->addTableStyle('myTable', $tableStyle1, $firstRowStyle);
                $table = $section->addTable('myTable');
                $table->addRow(150);
                $table->addCell(150)->addImage('public/static/index/word/jyjl.jpg',$imageStyleheader);
                $table->addCell(8800)->addText('教育经历',array('name' => '微软雅黑','size'=>12,'color'=>'1B2232','bold'=>true),array('lineHeight'=>1.2,'indent'=>0.2));
                $section->addTextBreak();
                // $section->addText('',array('name' => '微软雅黑','size' => 10.5, 'color' => '1B2232','color'=>'1B2232'),array('lineHeight'=>0.5,'indent'=>0.8));
                $section->addText($arr['school_start1'].'/'.$arr['school_start2'].'--'.$arr['school_end1'].'/'.$arr['school_end2'].'    '.$arr['school'].'    '.$arr['specialty'],array('name' => '微软雅黑', 'size' => 10.5, 'color' => '1B2232','color'=>'1B2232'),array('lineHeight'=>1.7,'indent'=>0.8));
                //左浮动图标
                $table = $section->addTable('myTable');
                $table->addRow(30);
                $table->addCell(30)->addImage('public/static/index/word/gzjl.jpg',$imageStyleheader);
                $table->addCell(8900)->addText('工作经历',array('name' => '微软雅黑','size'=>12,'color'=>'1B2232','bold'=>true),array('lineHeight'=>1.2,'indent'=>0.2));
                $section->addTextBreak();
                // $section->addText('',array('name' => '微软雅黑','size' => 10.5, 'color' => '1B2232','color'=>'1B2232'),array('lineHeight'=>0.5,'indent'=>0.8));
                foreach ($arr['shixi_start1'] as $ks=> $vs) {
                        $section->addText($arr['shixi_start1'][$ks].'/'.$arr['shixi_start2'][$ks].'--'.$arr['shixi_end1'][$ks].'/'.$arr['shixi_end2'][$ks].'    '.$arr['shixi_company'][$ks].'    '.$arr['shixi_zw'][$ks].'    '.$arr['shixi_daiyu'][$ks],array('name' => '微软雅黑', 'size' => 10.5, 'color' => '1B2232','color'=>'1B2232'),array('lineHeight'=>1.7,'indent'=>0.8));
                }
                //左浮动图标
                $table = $section->addTable('myTable');
                $table->addRow(30);
                $table->addCell(30)->addImage('public/static/index/word/yynl.jpg',$imageStyleheader);
                $table->addCell(8900)->addText('语言能力',array('name' => '微软雅黑','size'=>12,'color'=>'1B2232','bold'=>true),array('lineHeight'=>1.2,'indent'=>0.2));
                $section->addText('',array('name' => '微软雅黑','size' => 10.5, 'color' => '1B2232','color'=>'1B2232'),array('lineHeight'=>0.5,'indent'=>0.8));
                $section->addText($arr['languages'],array('name' => '微软雅黑', 'size' => 10.5, 'color' => '1B2232','color'=>'1B2232'),array('lineHeight'=>1.7,'indent'=>0.8));
                //左浮动图标
                $table = $section->addTable('myTable');
                $table->addRow(30);
                $table->addCell(30)->addImage('public/static/index/word/qzyx.jpg',$imageStyleheader);
                $table->addCell(8900)->addText('求职意向',array('name' => '微软雅黑','size'=>12,'color'=>'1B2232','bold'=>true),array('lineHeight'=>1.2,'indent'=>0.2));
                $section->addTextBreak();
                // $section->addText('',array('name' => '微软雅黑', 'size' => 10.5, 'color' => '1B2232','color'=>'1B2232'),array('lineHeight'=>0.5,'indent'=>0.8));
                $section->addText($arr['intention'],array('name' => '微软雅黑', 'size' => 10.5, 'color' => '1B2232','color'=>'1B2232'),array('lineHeight'=>1.7,'indent'=>0.8));
                //左浮动图标
                $table = $section->addTable('myTable');
                $table->addRow(30);
                $table->addCell(30)->addImage('public/static/index/word/zwpj.jpg',$imageStyleheader);
                $table->addCell(8900)->addText('自我评价',array('name' => '微软雅黑','size'=>12,'color'=>'1B2232','bold'=>true),array('lineHeight'=>1.2,'indent'=>0.2));
                $section->addTextBreak();
                // $section->addText('',array('name' => '微软雅黑', 'size' => 10.5, 'color' => '1B2232','color'=>'1B2232'),array('lineHeight'=>0.5,'indent'=>0.8));
                $section->addText($arr['introduce'],array('name' => '微软雅黑', 'size' => 10.5, 'color' => '1B2232','color'=>'1B2232'),array('lineHeight'=>1.7,'indent'=>0.8));
                // 将文档保存为OOXML文件…
                $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
                $objWriter->save('uploads/word/resume'.$arr['id'].'.docx');
        }
        //测试简历
        public function test($arr,$time){

                copy('public/static/index/word/qzjl.docx','public/static/index/word/'.$time.'.docx');


            //头像和个人信息表格
            $imageStyletop = array(
                'width' => 150,
                'height' => 195,
                'wrappingStyle' => 'square',
                'positioning' => 'absolute',
                'posHorizontalRel' => 'margin',
                'posVerticalRel' => 'line',
            );
                //load template docx


                $image='http://n.sinaimg.cn/news/crawl/44/w550h294/20200723/4f4d-iwtqvyk4521648.jpg';

//                $newimgname = 'new_'.substr('.'.$arr['img_url'],strripos('.'.$arr['img_url'],'/')+1); //新图名称加后缀
//                $newimgurl = substr('.'.$arr['img_url'],0,strripos('.'.$arr['img_url'],'/')+1); //新图url/
//                copy(substr($arr['img_url'],1),substr($newimgurl,2).$newimgname); //复制原图到新图路径
//                $image = \think\Image::open($newimgurl.$newimgname);//新图路径 ./
//                $image->thumb(300, 390)->save($newimgurl.$newimgname,null,100); //压缩新图,质量100
                $newurl = resizeImage('.'.$arr['img_url'],$imageStyletop['width'],$imageStyletop['height']);//压缩图片
//                $newurl = $newimgurl.$newimgname;//新图
//            halt($newurl);
                $templateProcessor = new TemplateDocx('public/static/index/word/'.$time.'.docx');
               $templateProcessor->setImg('img_url', array(
//                    'src'  => substr($arr['img_url'],1), //图片路径
                    'src'  => substr($newurl['url'],1), //图片路径
//                    'src'  => substr($newurl,1), //图片路径
                ));
//            $table->addCell(4200)->addImage(resizeImage('.'.$arr['img_url'],$imageStyletop['width'],$imageStyletop['height']),$imageStyletop);
                //基础信息填写替换
                $templateProcessor->setValue('name', $arr['name']);
                $templateProcessor->setValue('sex', $arr['sex']);
                $templateProcessor->setValue('birthday', $arr['birthday1'].'-'.$arr['birthday2']);

                $templateProcessor->setValue('education', $arr['education']);
                $templateProcessor->setValue('wechat', $arr['wechat']);
                $templateProcessor->setValue('years', $arr['years']);
                $templateProcessor->setValue('qualification', $arr['qualification']);
                $templateProcessor->setValue('tel', $arr['tel']);
                $templateProcessor->setValue('newaddress', $arr['newaddress']);
                $templateProcessor->setValue('email', $arr['email']);
                $templateProcessor->setValue('address', $arr['address']);
                $templateProcessor->setValue('gongzuoxingzhi', $arr['gongzuoxingzhi']);
                $templateProcessor->setValue('qiyexingzhi', $arr['qiyexingzhi']);
                $templateProcessor->setValue('xiwanghangye', $arr['xiwanghangye']);
                $templateProcessor->setValue('mubiaodidian', $arr['mubiaodidian']);
                $templateProcessor->setValue('mubiaozhiwei', $arr['mubiaozhiwei']);
                $templateProcessor->setValue('daiyuyaoqiu', $arr['daiyuyaoqiu']);
                $templateProcessor->setValue('introduce', $arr['introduce']);

                if(!empty($arr['shixi_start1'])){//工作经历最多两段
                        if(count($arr['shixi_start1']==2)){
                                $templateProcessor->setValue('shixi_company1', $arr['shixi_company'][0]);
                                $templateProcessor->setValue('shixi_companyhangye1', $arr['shixi_companyhangye'][0]);
                                $templateProcessor->setValue('shixi_bm1', $arr['shixi_bm'][0]);
                                $templateProcessor->setValue('shixi_zw1', $arr['shixi_zw'][0]);
                                $templateProcessor->setValue('shixi_daiyu1', $arr['shixi_daiyu'][0]);
                                $templateProcessor->setValue('shixi_gzmiaoshu1', $arr['shixi_gzmiaoshu'][0]);
                                $templateProcessor->setValue('shixi_lizhiyuanyin1', $arr['shixi_lizhiyuanyin'][0]);
                                $templateProcessor->setValue('shixi_start1', $arr['shixi_start1'][0].'-'.$arr['shixi_start2'][0]);
                                $templateProcessor->setValue('shixi_end1', $arr['shixi_end1'][0].'-'.$arr['shixi_end2'][0]);

                                $templateProcessor->setValue('shixi_company2', $arr['shixi_company'][1]);
                                $templateProcessor->setValue('shixi_companyhangye2', $arr['shixi_companyhangye'][1]);
                                $templateProcessor->setValue('shixi_bm2', $arr['shixi_bm'][1]);
                                $templateProcessor->setValue('shixi_zw2', $arr['shixi_zw'][1]);
                                $templateProcessor->setValue('shixi_daiyu2', $arr['shixi_daiyu'][1]);
                                $templateProcessor->setValue('shixi_gzmiaoshu2', $arr['shixi_gzmiaoshu'][1]);
                                $templateProcessor->setValue('shixi_lizhiyuanyin2', $arr['shixi_lizhiyuanyin'][1]);
                                $templateProcessor->setValue('shixi_start2', $arr['shixi_start1'][1].'-'.$arr['shixi_start2'][1]);
                                $templateProcessor->setValue('shixi_end2', $arr['shixi_end1'][1].'-'.$arr['shixi_end2'][1]);
                        }else{ //只有一段
                                $templateProcessor->setValue('shixi_company1', $arr['shixi_company'][0]);
                                $templateProcessor->setValue('shixi_companyhangye1', $arr['shixi_companyhangye'][0]);
                                $templateProcessor->setValue('shixi_bm1', $arr['shixi_bm'][0]);
                                $templateProcessor->setValue('shixi_zw1', $arr['shixi_zw'][0]);
                                $templateProcessor->setValue('shixi_daiyu1', $arr['shixi_daiyu'][0]);
                                $templateProcessor->setValue('shixi_gzmiaoshu1', $arr['shixi_gzmiaoshu'][0]);
                                $templateProcessor->setValue('shixi_lizhiyuanyin1', $arr['shixi_lizhiyuanyin'][0]);
                                $templateProcessor->setValue('shixi_start1', $arr['shixi_start1'][0].'-'.$arr['shixi_start2'][0]);
                                $templateProcessor->setValue('shixi_end1', $arr['shixi_end1'][0].'-'.$arr['shixi_end2'][0]);
                        }
                }

                if(!empty($arr['xuexi_start1'])){//学习经历最多三段
                        if(count($arr['xuexi_start1']==3)){
                                $templateProcessor->setValue('school_name1', $arr['school_name'][0]);
                                $templateProcessor->setValue('school_zhuanye1', $arr['school_zhuanye'][0]);
                                $templateProcessor->setValue('school_zz1', $arr['school_zz'][0]);
                                $templateProcessor->setValue('xuexi_start1', $arr['xuexi_start1'][0].'-'.$arr['xuexi_start2'][0]);
                                $templateProcessor->setValue('xuexi_end1', $arr['xuexi_end1'][0].'-'.$arr['xuexi_end2'][0]);

                                $templateProcessor->setValue('school_name2', $arr['school_name'][1]);
                                $templateProcessor->setValue('school_zhuanye2', $arr['school_zhuanye'][1]);
                                $templateProcessor->setValue('school_zz2', $arr['school_zz'][1]);
                                $templateProcessor->setValue('xuexi_start2', $arr['xuexi_start1'][1].'-'.$arr['xuexi_start2'][1]);
                                $templateProcessor->setValue('xuexi_end2', $arr['xuexi_end1'][1].'-'.$arr['xuexi_end2'][1]);

                                $templateProcessor->setValue('school_name3', $arr['school_name'][2]);
                                $templateProcessor->setValue('school_zhuanye3', $arr['school_zhuanye'][2]);
                                $templateProcessor->setValue('school_zz3', $arr['school_zz'][2]);
                                $templateProcessor->setValue('xuexi_start3', $arr['xuexi_start1'][2].'-'.$arr['xuexi_start2'][2]);
                                $templateProcessor->setValue('xuexi_end3', $arr['xuexi_end1'][2].'-'.$arr['xuexi_end2'][2]);
                        }elseif(count($arr['xuexi_start1']==2)){ //只有2段
                                $templateProcessor->setValue('school_name1', $arr['school_name'][0]);
                                $templateProcessor->setValue('school_zhuanye1', $arr['school_zhuanye'][0]);
                                $templateProcessor->setValue('school_zz1', $arr['school_zz'][0]);
                                $templateProcessor->setValue('xuexi_start1', $arr['xuexi_start1'][0].'-'.$arr['xuexi_start2'][0]);
                                $templateProcessor->setValue('xuexi_end1', $arr['xuexi_end1'][0].'-'.$arr['xuexi_end2'][0]);

                                $templateProcessor->setValue('school_name2', $arr['school_name'][1]);
                                $templateProcessor->setValue('school_zhuanye2', $arr['school_zhuanye'][1]);
                                $templateProcessor->setValue('school_zz2', $arr['school_zz'][1]);
                                $templateProcessor->setValue('xuexi_start2', $arr['xuexi_start1'][1].'-'.$arr['xuexi_start2'][1]);
                                $templateProcessor->setValue('xuexi_end2', $arr['xuexi_end1'][1].'-'.$arr['xuexi_end2'][1]);
                        }else{
                                $templateProcessor->setValue('school_name1', $arr['school_name'][0]);
                                $templateProcessor->setValue('school_zhuanye1', $arr['school_zhuanye'][0]);
                                $templateProcessor->setValue('school_zz1', $arr['school_zz'][0]);
                                $templateProcessor->setValue('xuexi_start1', $arr['xuexi_start1'][0].'-'.$arr['xuexi_start2'][0]);
                                $templateProcessor->setValue('xuexi_end1', $arr['xuexi_end1'][0].'-'.$arr['xuexi_end2'][0]);
                        }
                }

                $templateProcessor->saveAs('public/static/index/word/'.$time.'.docx');

        }

}